{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Comp. Ops & Statements "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Comparision operators are used for the comparing two or more data types for checking them are the equal, not equal, greater than, less than,"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "a = 10\n",
    "b = 20"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Equals to ?\n",
    "\n",
    "a == b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Not equal to ?\n",
    "\n",
    "a != b "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Greater than \n",
    "\n",
    "a > b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Less than \n",
    "\n",
    "a <b "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Greater than equal to\n",
    "\n",
    "a>=b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Less than Equal to ?\n",
    "\n",
    "a <= b"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chained Comp. Operators "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Which check two statements and get the ans, in true or false, \n",
    "\n",
    "With respect to the condition\n",
    "\n",
    "like, AND, OR and Not "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "False and True "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "True and True "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "a = 10\n",
    "b = 20"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a != b and b > a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# OR \n",
    "\n",
    "True or False "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "False or False "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a > b or a !=b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [],
   "source": [
    "# not "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "not (a != b)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#  if else and elif "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {},
   "outputs": [],
   "source": [
    "isCycloneThere = True \n",
    "isCovidThere = False \n",
    "isItMandtory = False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "DONT GO OUT OF HOME\n"
     ]
    }
   ],
   "source": [
    "if isCycloneThere :\n",
    "    print(\"DONT GO OUT OF HOME\")\n",
    "elif isCovidThere :\n",
    "    print(\"Still dont go out home but if u want carry mask\")\n",
    "elif isItMandtory:\n",
    "    print(\"Ok go where ever u want \")\n",
    "else:\n",
    "    print(\"You can go out of ur home Freely, enjoying freedom\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hey u r in the software\n"
     ]
    }
   ],
   "source": [
    "password = \"letsupgradeBatch4\"\n",
    "\n",
    "if password == \"letsupgradeBatch4\":\n",
    "    print(\"Hey u r in the software\")\n",
    "else:\n",
    "    print(\"Wrng password type again\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Enter ur Numbers56\n",
      "56\n"
     ]
    }
   ],
   "source": [
    "some_input = input(\"Enter ur Numbers\")\n",
    "\n",
    "print(some_input)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "team india score = 178\n",
    "\n",
    "userhas to guess the score = 100\n",
    "\n",
    "now we know that, 178 -100 = 78> 10 that means, \n",
    "our guess is wrng\n",
    "\n",
    "if ur guess is below 10 then print -> u r true fan, "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# For Loops "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Loops are used when u want to iteration to bbe done on any kind of object "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "metadata": {},
   "outputs": [],
   "source": [
    "lst = list(range(1,100))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "metadata": {},
   "outputs": [],
   "source": [
    "lst1 = [\"Apple\",\"Banana\",\"Cherry\",\"Donkey\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Apple\n",
      "Are u understading ? the class\n",
      "Banana\n",
      "Are u understading ? the class\n",
      "Cherry\n",
      "Are u understading ? the class\n",
      "Donkey\n",
      "Are u understading ? the class\n"
     ]
    }
   ],
   "source": [
    "for item in lst1:\n",
    "    print(item)\n",
    "    print(\"Are u understading ? the class\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "metadata": {},
   "outputs": [],
   "source": [
    "#use For loop for printing the cube of first 10 natural numbers ?\n",
    "\n",
    "lst = list(range(1,11))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]"
      ]
     },
     "execution_count": 70,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "lst"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1  cube = 1\n",
      "2  cube = 8\n",
      "3  cube = 27\n",
      "4  cube = 64\n",
      "5  cube = 125\n",
      "6  cube = 216\n",
      "7  cube = 343\n",
      "8  cube = 512\n",
      "9  cube = 729\n",
      "10  cube = 1000\n"
     ]
    }
   ],
   "source": [
    "for item in lst:\n",
    "    cube = item * item * item\n",
    "    print(item,\" cube =\", cube)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]"
      ]
     },
     "execution_count": 72,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "lst"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1  X  1  =  1\n",
      "1  X  2  =  2\n",
      "1  X  3  =  3\n",
      "1  X  4  =  4\n",
      "1  X  5  =  5\n",
      "1  X  6  =  6\n",
      "1  X  7  =  7\n",
      "1  X  8  =  8\n",
      "1  X  9  =  9\n",
      "1  X  10  =  10\n",
      "----------\n",
      "2  X  1  =  2\n",
      "2  X  2  =  4\n",
      "2  X  3  =  6\n",
      "2  X  4  =  8\n",
      "2  X  5  =  10\n",
      "2  X  6  =  12\n",
      "2  X  7  =  14\n",
      "2  X  8  =  16\n",
      "2  X  9  =  18\n",
      "2  X  10  =  20\n",
      "----------\n",
      "3  X  1  =  3\n",
      "3  X  2  =  6\n",
      "3  X  3  =  9\n",
      "3  X  4  =  12\n",
      "3  X  5  =  15\n",
      "3  X  6  =  18\n",
      "3  X  7  =  21\n",
      "3  X  8  =  24\n",
      "3  X  9  =  27\n",
      "3  X  10  =  30\n",
      "----------\n",
      "4  X  1  =  4\n",
      "4  X  2  =  8\n",
      "4  X  3  =  12\n",
      "4  X  4  =  16\n",
      "4  X  5  =  20\n",
      "4  X  6  =  24\n",
      "4  X  7  =  28\n",
      "4  X  8  =  32\n",
      "4  X  9  =  36\n",
      "4  X  10  =  40\n",
      "----------\n",
      "5  X  1  =  5\n",
      "5  X  2  =  10\n",
      "5  X  3  =  15\n",
      "5  X  4  =  20\n",
      "5  X  5  =  25\n",
      "5  X  6  =  30\n",
      "5  X  7  =  35\n",
      "5  X  8  =  40\n",
      "5  X  9  =  45\n",
      "5  X  10  =  50\n",
      "----------\n",
      "6  X  1  =  6\n",
      "6  X  2  =  12\n",
      "6  X  3  =  18\n",
      "6  X  4  =  24\n",
      "6  X  5  =  30\n",
      "6  X  6  =  36\n",
      "6  X  7  =  42\n",
      "6  X  8  =  48\n",
      "6  X  9  =  54\n",
      "6  X  10  =  60\n",
      "----------\n",
      "7  X  1  =  7\n",
      "7  X  2  =  14\n",
      "7  X  3  =  21\n",
      "7  X  4  =  28\n",
      "7  X  5  =  35\n",
      "7  X  6  =  42\n",
      "7  X  7  =  49\n",
      "7  X  8  =  56\n",
      "7  X  9  =  63\n",
      "7  X  10  =  70\n",
      "----------\n",
      "8  X  1  =  8\n",
      "8  X  2  =  16\n",
      "8  X  3  =  24\n",
      "8  X  4  =  32\n",
      "8  X  5  =  40\n",
      "8  X  6  =  48\n",
      "8  X  7  =  56\n",
      "8  X  8  =  64\n",
      "8  X  9  =  72\n",
      "8  X  10  =  80\n",
      "----------\n",
      "9  X  1  =  9\n",
      "9  X  2  =  18\n",
      "9  X  3  =  27\n",
      "9  X  4  =  36\n",
      "9  X  5  =  45\n",
      "9  X  6  =  54\n",
      "9  X  7  =  63\n",
      "9  X  8  =  72\n",
      "9  X  9  =  81\n",
      "9  X  10  =  90\n",
      "----------\n",
      "10  X  1  =  10\n",
      "10  X  2  =  20\n",
      "10  X  3  =  30\n",
      "10  X  4  =  40\n",
      "10  X  5  =  50\n",
      "10  X  6  =  60\n",
      "10  X  7  =  70\n",
      "10  X  8  =  80\n",
      "10  X  9  =  90\n",
      "10  X  10  =  100\n",
      "----------\n"
     ]
    }
   ],
   "source": [
    "for baseNumber in lst:\n",
    "    for multiplNumber in lst:\n",
    "        print(baseNumber, \" X \", multiplNumber, \" = \", baseNumber*multiplNumber)\n",
    "    print(\"----------\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# While Loop "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "metadata": {},
   "outputs": [
    {
     "ename": "IndentationError",
     "evalue": "unindent does not match any outer indentation level (<tokenize>, line 5)",
     "output_type": "error",
     "traceback": [
      "\u001b[0;36m  File \u001b[0;32m\"<tokenize>\"\u001b[0;36m, line \u001b[0;32m5\u001b[0m\n\u001b[0;31m    ***\u001b[0m\n\u001b[0m    ^\u001b[0m\n\u001b[0;31mIndentationError\u001b[0m\u001b[0;31m:\u001b[0m unindent does not match any outer indentation level\n"
     ]
    }
   ],
   "source": [
    "# Assignment Number 5 using for loops print this ... \n",
    "\n",
    "\n",
    "   *    \n",
    "  ***   \n",
    " *****  \n",
    "*******\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 93,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hi\n",
      " HI Ranjan\n"
     ]
    }
   ],
   "source": [
    "i = 0\n",
    "while True:\n",
    "    print(\"Hi\")\n",
    "    print(\" HI Ranjan\")\n",
    "    i += 1\n",
    "else:\n",
    "    print(\"While Ended!\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 95,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "3\n",
      "5\n",
      "7\n",
      "9\n",
      "11\n",
      "13\n",
      "15\n",
      "17\n",
      "19\n",
      "21\n",
      "23\n",
      "25\n",
      "27\n",
      "29\n",
      "31\n",
      "33\n",
      "35\n",
      "37\n",
      "39\n",
      "41\n",
      "43\n",
      "45\n",
      "47\n",
      "49\n",
      "51\n",
      "53\n",
      "55\n",
      "57\n",
      "59\n",
      "61\n",
      "63\n",
      "65\n",
      "67\n",
      "69\n",
      "71\n",
      "73\n",
      "75\n",
      "77\n",
      "79\n",
      "81\n",
      "83\n",
      "85\n",
      "87\n",
      "89\n",
      "91\n",
      "93\n",
      "95\n",
      "97\n",
      "99\n"
     ]
    }
   ],
   "source": [
    "i = 0 \n",
    "while i<= 100:\n",
    "    if i%2 != 0:\n",
    "        print(i)\n",
    "    i+=1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 98,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "3\n",
      "5\n",
      "7\n",
      "9\n",
      "11\n",
      "13\n",
      "15\n",
      "17\n",
      "19\n",
      "21\n",
      "23\n",
      "25\n",
      "27\n",
      "29\n",
      "31\n",
      "33\n",
      "35\n",
      "37\n",
      "39\n",
      "41\n",
      "43\n",
      "45\n",
      "47\n",
      "49\n",
      "51\n",
      "53\n",
      "55\n",
      "57\n",
      "59\n",
      "61\n",
      "63\n",
      "65\n",
      "67\n",
      "69\n",
      "71\n",
      "73\n",
      "75\n",
      "77\n",
      "79\n",
      "81\n",
      "83\n",
      "85\n",
      "87\n",
      "89\n",
      "91\n",
      "93\n",
      "95\n",
      "97\n",
      "99\n"
     ]
    }
   ],
   "source": [
    "for item in range(1,100):\n",
    "    if item%2 != 0:\n",
    "        print(item)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 99,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Break, Continue and Pass "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 100,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "5\n"
     ]
    }
   ],
   "source": [
    "#Break ? - When we want to break a vechile ?\n",
    "i= 0\n",
    "while i < 10:\n",
    "    print(i)\n",
    "    if i == 5:\n",
    "        break\n",
    "    i +=1\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 105,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "6\n",
      "7\n",
      "8\n",
      "9\n",
      "10\n"
     ]
    }
   ],
   "source": [
    "# Continue \n",
    "\n",
    "# Stop and go - Traffic Singnals - Stop, skip some time, and go \n",
    "\n",
    "i= 0\n",
    "while i < 10:\n",
    "    i +=1\n",
    "    if i == 5:\n",
    "        continue\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 110,
   "metadata": {},
   "outputs": [],
   "source": [
    "# pass ?\n",
    "\n",
    "# pass is just when u dont have any code right now ready\n",
    "#but u want to make sure that ur programs dosent break \n",
    "\n",
    "for item in range(10):\n",
    "    pass"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
